package com.smartfactory.sail.controller;


import com.ada.base.common.ApiResponse;
import com.ada.base.common.ControllerResponse;
import com.smartfactory.sail.entity.ItemWorkingprocedure;
import com.smartfactory.sail.service.IItemWorkingprocedureService;
import com.smartfactory.sail.vo.item.ItemWorkingprocedureResp;
import com.smartfactory.sail.vo.item.ItemWorkingprocedureSimpleResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 产品工序表 前端控制器
 * </p>
 *
 * @author 王巨壁
 * @since 2019-08-13
 */
@Api(tags = "产品工序")
@RestController
@RequestMapping("/item-workingprocedure")
public class ItemWorkingprocedureController extends ControllerResponse {
    private IItemWorkingprocedureService iItemWorkingprocedureService;

    public ItemWorkingprocedureController(IItemWorkingprocedureService iItemWorkingprocedureService) {
        this.iItemWorkingprocedureService = iItemWorkingprocedureService;
    }

    @GetMapping("/{itemId}/{dept}")
    @ApiOperation(value = "产品工序列表", notes = "产品工序列表")
    public ApiResponse<List<ItemWorkingprocedure>> list(@PathVariable("itemId") long itemId, @PathVariable("dept") long dept) {
        return ok(iItemWorkingprocedureService.findByItemId(itemId, dept));
    }

    @GetMapping("/{orderId}/{itemId}/{dept}")
    @ApiOperation(value = "订单产品工序详情", notes = "订单产品工序详情")
    public ApiResponse<List<ItemWorkingprocedureResp>> detail(@PathVariable("orderId") long orderId, @PathVariable("itemId") long itemId, @PathVariable("dept") long dept) {
        return ok(iItemWorkingprocedureService.detail(orderId, itemId, dept));
    }

    @GetMapping("/percent/{orderId}/{itemId}/{dept}")
    @ApiOperation(value = "订单产品工序进度", notes = "订单产品工序进度")
    public ApiResponse<List<ItemWorkingprocedureSimpleResp>> simple(@PathVariable("orderId") long orderId, @PathVariable("itemId") long itemId, @PathVariable("dept") long dept) {
        return ok(iItemWorkingprocedureService.simple(orderId, itemId, dept));
    }
}
